package sorting;

import java.util.Arrays;

//You can call the methods with their names (references) with :: operator.

class Test {
    public static int matchStringLength(String str1, String str2) {
        return str1.length() - str2.length();
    }
}

public class ArraySort {
    public void printByStringLength() {
        String names[] = { "abcde", "abc", "ab", "abcd", "a" };
        Arrays.sort(names, Test::matchStringLength);
        System.out.println(Arrays.toString(names));
    }

    public static void main(String args[]) {
        new ArraySort().printByStringLength();
    }
}
